package ch.zbw.swt.sysventory.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Toolkit;

import javax.swing.AbstractListModel;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import IMG.GetPath;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/*
 * GUI zeigt alle erfassten Software aus der DB an
 */

public class GUIStatistikSoftware extends JFrame {

	//Panel
	private JPanel panel_1;
	private JPanel panel;
	
	private JScrollPane scrollPane;
	
	//Tabelle
	private JTable table;
	
	//Bidler
	private ImageIcon goArrow;
	private ImageIcon backArrow;
	
	//labels
	private JLabel labeltitelMenu;
	
	//Buttons
	private JButton back2MenuButton;
	
	//Listener
	private Action action;

	
	/**
	 * Konstruktor für GUI
	 */
	public GUIStatistikSoftware(Action action) {
		this.action = action;
	
	}

	/**
	 * Initialisierung der GUI 
	 */
	public void initialize() {
		
		//Eingenschaften der GUI
		this.getContentPane().setBackground(Color.WHITE);
		this.setBackground(Color.WHITE);
		this.setBounds(100, 100, 770, 480);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		//Einmittung
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int top = (screenSize.height - this.getHeight()) / 2;
		int left = (screenSize.width - this.getWidth()) / 2;
		this.setLocation(left, top);
		
		//weitere Eingeschaften der GUI
		this.setResizable(false);
		this.setVisible(true);
		
		//Einfügen der Elemente
		panel = new JPanel();
		panel.setBackground(Color.WHITE);
		panel.setBounds(10, 11, 744, 83);
		this.getContentPane().add(panel);
		panel.setLayout(null);
		
		goArrow = new ImageIcon(GetPath.class.getResource("go.png"));			
		backArrow = new ImageIcon(GetPath.class.getResource("back.png"));
		
		labeltitelMenu = new JLabel("Software");
		labeltitelMenu.setFont(new Font("Impact", Font.PLAIN, 36));
		labeltitelMenu.setBounds(322, 11, 209, 61);
		panel.add(labeltitelMenu);
		
		back2MenuButton = new JButton(backArrow);
		back2MenuButton.setBackground(Color.WHITE);
		back2MenuButton.setBounds(24, 11, 129, 61);
		back2MenuButton.setBorder(null);
		panel.add(back2MenuButton);
		
		panel_1 = new JPanel();
		panel_1.setBounds(10, 155, 744, 286);
		panel.add(panel_1);
		panel_1.setLayout(new BorderLayout(0, 0));
		
		scrollPane = new JScrollPane();
		panel_1.add(scrollPane);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
			},
			new String[] {
				"Software", "Datum", "Version"
			}
		));
		table.getColumnModel().getColumn(0).setPreferredWidth(87);
		table.getColumnModel().getColumn(0).setMinWidth(87);
		scrollPane.setViewportView(table);
		
		//Einfügen der Actionlistener
		
		back2MenuButton.addActionListener(action);
		back2MenuButton.setActionCommand("back2Menu");
		
	}

}
